$(XEN_ROOT) absolutification fixes for ioemu-remote (incl stubdom)
* Move code for generating an absolute version of XEN_ROOT
into a common make variable set in Config.mk
* Use this common code when invoking make -C ioemu-dir clean
from tools/, which avoids a problem where `make clean' fails
because qemu's (ioemu-remote's) build system wants to run
`make clean' in `tests' but XEN_ROOT is a confection involving
../'s.
* Use this common code in stubdom/Makefile, instead of $(abspath...)
as the latter is a relatively new feature in GNU make and is not
available in all the places that we want to be able to build
(cf c/s 17997:3f23e01d31985899dbd1660b166f229f1ee74292)
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
- This patch corrects an unsafe/incorrect usage of FOREIGNDOM. The
value of FOREIGNDOM is now passed through the XSM interface.
Corresponding updates to the Flask module are included in this patch.
- This patch also includes a minor header update to allow the Flask
module to compile after recent updates to Xen.
Signed-off-by: George Coker <gscoker@alpha.ncsc.mil>
CPUIDLE: Port Linux menu governor to replace the initial ladder governor
The ladder governor has long pro/demotion delay shortcome while
applying to tickless mode, because it needs to count usage. Menu
governor chooses the next state simply via break-event prediction
including the factors of next timer event & last residency time etc,
so it would have faster response speed.
CPUIDLE: Avoid remnant LAPIC timer intr while force hpetbroadcast
LAPIC will stop during C3, and resume to work after exit from
C3. Considering below case:
The LAPIC timer was programmed to expire after 1000us, but CPU enter
C3 after 100us and exit C3 at 9xxus.
0us: reprogram_timer(1000us)
100us: entry C3, LAPIC timer stop
9xxus: exit C3 due to unexpected event, LAPIC timer continue running
10xxus: reprogram_timer(1000us), fail due to the past expiring time.
......: no timer softirq raised, no change to LAPIC timer.
......: if entry C3 again, HPET will be forced reprogramed to
now+small_slop.
......: if entry C2, no change to LAPIC.
18xxus: LAPIC timer expires unexpectedly if no C3 entries after
10xxus.
CPUIDLE: Avoid remnant HPET intr while force hpetbroadcast
Exit from C3 is mainly caused by HPET intr if force enable
hpetbroadcast. But it is still probably caused by other unexpected
events. In this case the HPET timer may still be alive while there is
no CPU in C3. Avoid those remnant HPET intr can save cpu handling time
and increase idle time.
vtd: Add a command line param to enable/disable pass-through feature
Taking security into accout, it's not suitable to bypass VT-d
translation for Dom0 by default when the pass-through field in
extended capability register is set. This feature is for people/usages
who are not overly worried about security/isolation, but want better
performance.
This patch adds a command line param that controls if it's enabled or
disabled.
Signed-off-by: Weidong Han <weidong.han@intel.com>
x86, xend: Fix processing of cpuid config parameters
There is an python indentation issue keeping the full range of syntax
for the cpuid config file parameter from working correctly. This
patch fixes that. It also fixes some misspelling and a missing 'x' in
two of the example config files (must have 32 bits represented for
cpuid registers).
This small patch fixes an issue leading to a crash (segfault, although
with earlier changesets I was seeing sigbus - not sure what changed)
in qemu-dm when the following conditions occur:
1. A valid mapping for a bucket on a low address exists
2. Immediately after accessing memory mapped in this bucket, an access
occurs to a high (beyond assigned ram) address beyond the 1GB limit
for 32bit map cache wrapping around to the previous bucket's entry
number.
3. The next call to map cache again accesses the low address.
In this scenario, the guest mem for the low bucket has been unmapped
by the remap_bucket caused by 2., but because the valid_mapping
bit-test fails, map_cache returns before last_address_index has been
updated. The subsequent call to map_cache therefore never remaps the
low, valid bucket and instead returns a vaddr pointing to memory that
has failed to get mapped.
If pass-through field in extended capability register is set, set
pass-through translation type for Dom0, that means DMA requests with
Untranslated addresses are processed as pass-through in Dom0, needn't
translate DMA requests through a multi-level page-table.
Signed-off-by: Anthony Xu <anthony.xu@intel.com> Signed-off-by: Weidong Han <weidong.han@intel.com>
xentrace 3/7: Remove vcpu / domain from HVM traces.
This information is now redundant, as it can be determined using
runstate changes and lost record changes. This reduces log size for
long-running traces by 10-30%.
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com> Signed-off-by: Trolle Selander <trolle.selander@eu.citrix.com>
xentrace 2/7: Lost-records record includes currently running vcpu,
and tsc of first lost record.
Including the current vcpu helps us identify who's currently
running on each processor, even if we've lost records. The tsc of the
first lost record helps us identify how much time we've spent lost,
and also when a pcpu started experiencing lost records.
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com> Signed-off-by: Trolle Selander <trolle.selander@eu.citrix.com>
cpufreq_dom_mask must not be confined to the number of CPUs in the
system - there's nothing disallowing e.g. 1-based domain identifiers
to be used in _PSD. It still remains risky to assume that these
numbers are 'small' and/or not allocated sparsely.
xc_save: ignore the first suspend event channel notification
I've noticed that the suspend event channel becomes pending as soon as
it is bound. I'm not sure why or whether this is intentional, but it
means that the suspend function will return before the domain has
completed suspending unless the first notification is cleared. Without
this patch, xc_domain_save may find that the guest has not suspended
and sleep in 10ms chunks until it does. Typically this is several
milliseconds of wasted time.
Current code does not set dev->msix->table_off variable.
The offset of MSI-X memory mapped table is treated as 0.
The wrong region is unmapped from guest physical memory space.
As a result, guest device driver can't access memory mapped resource.
- The patch includes a policy for xen that can be booted into
enforcing mode and supports creation and management of
paravirtualized guests. The policy follows the dom0/domU usage
model, extension to other models or the addition of management or IO
permissions should be much more straightforward now. The option
flask_enforcing=1 can be passed on the xen line in grub to boot
into enforcing mode.
- The policy provides a basic policy for booting the platform and
creating a domU with the label system_u:object_r:domU_t. The policy
can be easily extended to support new types by modifying the xen.te
source file.
- The policy includes some basic macros which may be helpful in
extending the policy.
- The policy is compatible with and requires the most recent XSM
patch, xsm-flask-io-sysctl-hooks-090308.diff.
- The policy is not built as part of the make all as it requires the
SELinux policy compiler which may/may not be installed on all
systems. Users must go into the tools/flask/policy directory and
explicitly compile the policy.
Signed-off-by: George Coker <gscoker@alpha.ncsc.mil>
- The patch refactors the IO resource checks into the rangeset add/del
code. This produces a much more architecture friendly implementation and
ensures that HVM and paravirtualized guests are checked consistently.
- The patch removes the following hooks in support of the refactoring
of the IO resource checks:
- xsm_irq_permission
- xsm_iomem_permission
- xsm_ioport_permission
- The patch adds the following hooks in support of the refactoring of
the IO resource checks:
- xsm_add_range
- xsm_remove_range
- These IO refactoring changes are transparent to any pre-existing
Flask policies.
- The patch adds also adds hooks for sysctl functionality that was
added since the last major XSM patch. The following hooks were added:
- xsm_set_target
- xsm_debug_keys
- xsm_getcpuinfo
- xsm_availheap
- xsm_firmware_info
- xsm_acpi_sleep
- xsm_change_freq
- xsm_getidletime
- xsm_sendtrigger
- xsm_test_assign_device
- xsm_assign_device
- xsm_deassign_device
- xsm_bind_pt_irq
- xsm_pin_mem_cacheattr
- xsm_ext_vcpucontext
Signed-off-by: George Coker <gscoker@alpha.ncsc.mil>
- The patch does away with the autogenerated xsm.py file and
introduces a config parameter in xend-config.sxp to determine the
security module. The parameter is (xsm_module_name {acm, dummy,
flask}). The default setting/option is dummy. .hgignore is also
updated to stop ignoring xsm.py on commits.
- The patch has created an xsconstant for XS_POLICY_FLASK and updated
the toolchain to check the instance of XS_POLICY_USE. XS_POLICY_USE
evalauates to XS_POLICY_FLASK or XS_POLICY_ACM or XS_POLICY_DUMMY
depending on configuration.
- Flask relies on the current value of ssidref returned by dominfo to
ensure that the label to sid mapping is consistent. ssidref had
been pop'ed from the dominfo object. The patch addresses this
issue.
- Flask python module style cleanups.
Signed-off-by: George Coker <gscoker@alpha.ncsc.mil>
The guest handle checks should use paging_* predicates, not shadow_*.
Also tidy up a few places where p2m definitions were being imported
via asm/guest_access.h -> asm/shadow.h -> asm/p2m.h
Idle vcpu periodic timer is useless. It increased the lapic timer
interrupt number, which decreased the cpu idle residency. This patch
disables idle vcpu periodic timer via keeping v->periodic_period = 0.
The vcpu periodic timer may be expired 50us before expected time
because there is a 50us TIMER_SLOP used for soft timer (xen/common/timer.c,
timer_softirq_action()). This will cause vcpu_periodic_timer_work() be
continuously called tens of times in a single call of
timer_softirq_action() until (now > periodic_next_event). It brings
unnecessary overhead. This patch adds a similar time slop in vcpu
periodic timer to eliminate this overhead.
xend: move the call to XendDevices.destroy_device_state()
This patch moves the call to XendDevices.destroy_device_state() to the
function _remove_domain. Previously only Xen-API calls were calling
the destroy_device_state() function.
Linux 2.6.27 adds code to enable extended config space accesses in the
Northbridge Configuration MSR; Xen should allow Dom0 to control the
respective bit.
Likewise, 2.6.26 added support to enable the MMIO config space access
method for certain Sun systems, so similarly Xen should allow Dom0 to
control the respective fields of the MMIO Configuration Base Address
Register.
ioemu: fix multiple pci-attach/pci-detach by removing the meaningless irq_index
For HVM guest, we can't do pci-attach/pci-detach for >64 times due to
the meaningless checking in pci_register_device(). I made a test of
300 times of attach/detach and everything now works well.
Keir Fraser [Fri, 29 Aug 2008 15:16:33 +0000 (16:16 +0100)]
vtd: fix Dom0 S3 when VT-d is enabled.
Now if VT-d is enabled, when Dom0 does S3, Xen doesn't suspend/resume
the IOMMU states.
The patch adds the missing invocations of
iommu_suspend()/iommu_resume() and makes some nesessary fixes:
1) In iommu_set_root_entry(), we should not re-allocate the root-entry
when Xen returns from S3;
2) Define the array iommu_state correctly (u8 -> u32);
3) Only save/restore the necessary IOMMU registers.
The patch was tested on Weybridge.
NOTE: if we have some HVM guests which have assigned devices, and we
want to do Dom S3, we MUST do HVM S3 for each HVM guest first.
Namely, the steps are:
1) Use HVM S3 in guest to suspend the guest (for example, in Linux HVM
guest, this is "echo mem > /sys/power/state");
2) Use Dom0 S3 to suspend Dom0: "echo mem > /sys/power/state";
3) At some point, Dom0 resumes from S3 (for example, by pressing the
power button or using the acpi alarm);
4) Use "xm trigger HVM_DOM_ID s3resume" to resume every HVM guest
which were suspended previously.
Keir Fraser [Fri, 29 Aug 2008 15:11:05 +0000 (16:11 +0100)]
x86: constify microcode hypercall argument
Linux 2.6.27 marks the data pointer in its firmware struct 'const',
and hence, to avoid a compiler warning, Xen's microcode update
interface should be properly properly constified too.
This is a cleanup patch. It combines destroyDomain() method
into destroy() method, then _prepare_phantom_paths() method and
_cleanup_phantom_devs() method are called only once.
Keir Fraser [Wed, 27 Aug 2008 14:02:38 +0000 (15:02 +0100)]
tools/xenmon/Makefile: Move LDFLAGS after $<
gcc expects libraries needed for object files to be specified after
the object. Linking usually does not fail, unless it is optimized (for
instance, using -Wl,-as-needed).
The related Gentoo bug is 135145 [ https://bugs.gentoo.org/135145 ].
From: Robert Buchholz <rbu@gentoo.org> Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
Keir Fraser [Wed, 27 Aug 2008 13:57:23 +0000 (14:57 +0100)]
ioemu: Add SEEK_STAT in all non-error cases except sleep request,
since our seek times are virtually 0. Although this flag is
deprecated by newer ATA standards, Linux at least checks it for CD
drives, and would timeout in some cases if we do not set it.
Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
Keir Fraser [Wed, 27 Aug 2008 13:53:39 +0000 (14:53 +0100)]
hvm: Use main memory for video memory.
When creating an HVM domain, if e.g. another domain is created before
qemu allocates video memory, the extra 8MB memory ballooning is not
available any more, because it got consumed by the other domain.
This fixes it by taking video memory from the main memory:
- make hvmloader use e820_malloc to reserve some of the main memory
and notify ioemu of its address through the Xen platform PCI card.
- add XENMAPSPACE_mfn to the xen_add_to_physmap memory op, to allow
ioemu to move the MFNs between the original position and the PCI
mapping, when LFB acceleration is disabled/enabled
- add a remove_from_physmap memory op, to allow ioemu to unmap it
completely for the case of old guests with acceleration disabled.
- add xc_domain_memory_translate_gpfn_list to libxc to allow ioemu to
get the MFNs of the video memory.
- have xend save the PCI memory space instead of ioemu: if a memory
page is there, the guest can access it like usual memory, so xend
can safely be responsible to save it. The extra benefit is that
live migration will apply the logdirty optimization there too.
- handle old saved images, populating the video memory from ioemu if
really needed.
Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
Keir Fraser [Wed, 27 Aug 2008 09:11:33 +0000 (10:11 +0100)]
x86: Assert in_irq() while processing guest-bound interrupts.
Actually a fair amount of infrastructure is onvolved these days, and
we'd like subsystems we call into know that we're in IRQ context so
they can handle that or BUG/ASSERT if appropriate.